home *** CD-ROM | disk | FTP | other *** search
/ GameStar 2005 October / Gamestar_77_2005-10_dvd.iso / Dema / betonsoldier_spdemo.exe / {app} / Shaders / glow_shader.fx < prev    next >
Encoding:
Text File  |  2005-07-05  |  25.1 KB  |  867 lines

  1. //------------------------------------------------------------------------------------------------------
  2. //------------------------------------------------------------------------------------------------------
  3. //------------------------------------------------------------------------------------------------------
  4.  
  5. #include "shared.fx"
  6.  
  7. //------------------------------------------------------------------------------------------------------
  8. //- Static parameters
  9. //------------------------------------------------------------------------------------------------------
  10.  
  11. //common things
  12. texture        SourceTexture1; // param 0
  13. texture        SourceTexture2;    // param 1
  14. texture        SourceTexture3;    // param 2
  15. texture        SourceTexture4;    // param 3
  16.  
  17. //glow things
  18.  
  19. float4        GlowThreshold;    // param 4
  20.  
  21. //blur things
  22. float            BlurStrength;        // param 5
  23. float            TextureWidth;        // param 6
  24. float            TextureHeight;    // param 7
  25.  
  26. //blend things
  27. float4        WeightSource1;    // param  8
  28. float4        WeightSource2;    // param  9
  29. float4        WeightSource3;    // param 10
  30. float4        WeightSource4;    // param 11
  31.  
  32. //fade color
  33. float4        Color;            
  34. float3        Time;
  35.  
  36. //------------------------------------------------------------------------------------------------------
  37. //------------------------------------------------------------------------------------------------------
  38. //------------------------------------------------------------------------------------------------------
  39.  
  40. struct    CVS_Base_Input
  41. {
  42.     float4    Position    :    POSITION;
  43.     float2    DiffuseUv    :    TEXCOORD0;    
  44. };
  45.  
  46. //------------------------------------------------------------------------------------------------------
  47.  
  48. struct    CVS_Base_Output
  49. {
  50.     float4    Position    :    POSITION;
  51.     float2    DiffuseUv    :    TEXCOORD0;    
  52. };
  53.  
  54. //------------------------------------------------------------------------------------------------------
  55. // Blended Vertex shader outputs
  56. //
  57. // the point is to duplicate uv in all channels (2 for a 2 tex blend, 3 for a 3 tex blend, 4 for a 4 tex blend...)
  58. //------------------------------------------------------------------------------------------------------
  59. struct    CVS_Blend2_Output
  60. {
  61.     float4    Position            :    POSITION;    
  62.     float2    DiffuseUv1        :    TEXCOORD0;
  63.     float2    DiffuseUv2        :    TEXCOORD1;    
  64. };
  65.  
  66. struct    CVS_Blend3_Output
  67. {
  68.     float4    Position            :    POSITION;    
  69.     float2    DiffuseUv1        :    TEXCOORD0;
  70.     float2    DiffuseUv2        :    TEXCOORD1;    
  71.     float2    DiffuseUv3        :    TEXCOORD2;    
  72. };
  73.  
  74. struct    CVS_Blend4_Output
  75. {
  76.     float4    Position            :    POSITION;    
  77.     float2    DiffuseUv1        :    TEXCOORD0;
  78.     float2    DiffuseUv2        :    TEXCOORD1;    
  79.     float2    DiffuseUv3        :    TEXCOORD2;    
  80.     float2    DiffuseUv4        :    TEXCOORD3;    
  81. };
  82.  
  83. //------------------------------------------------------------------------------------------------------
  84.  
  85. struct    CVS_Blur_Output
  86. {
  87.     float4    Position    :    POSITION;
  88.     float2    DiffuseN0    :    TEXCOORD0;
  89.     float2    DiffuseN1    :    TEXCOORD1;
  90.     float2    DiffuseN2    :    TEXCOORD2;
  91.     float2    DiffuseN3    :    TEXCOORD3;
  92.         
  93. };
  94.  
  95. //------------------------------------------------------------------------------------------------------
  96. //                                                                        VERTEX SHADERS DECLARATIONS
  97. //------------------------------------------------------------------------------------------------------
  98. CVS_Base_Output        VSBase                    (const CVS_Base_Input input);
  99. CVS_Blend2_Output    VSBlend2                (const CVS_Base_Input input);
  100. CVS_Blend3_Output    VSBlend3                (const CVS_Base_Input input);
  101. CVS_Blend4_Output    VSBlend4                (const CVS_Base_Input input);
  102. CVS_Blur_Output        HorizontalBlurVS(const CVS_Base_Input input);
  103. CVS_Blur_Output        VerticalBlurVS  (const CVS_Base_Input input);
  104.  
  105.  
  106. //------------------------------------------------------------------------------------------------------
  107. //                                                                    VERTEX SHADERS IMPLEMENTATIONS
  108. //------------------------------------------------------------------------------------------------------
  109.  
  110. //------------------------------------------------------------------------------------------------------
  111. // CVS_Base_Output    VSBase (const CVS_Base_Input input)
  112. //
  113. // simple position + uv transfer (UV correction is applied though)
  114. //------------------------------------------------------------------------------------------------------
  115. CVS_Base_Output    VSBase (const CVS_Base_Input input)
  116. {
  117.     CVS_Base_Output output;
  118.     
  119.     // output position into world+view+projection space
  120.     output.Position = input.Position;
  121.         
  122.     // Diffuse Uv output
  123.     output.DiffuseUv = input.DiffuseUv + (0.5f/TextureWidth, 0.5f/TextureHeight);
  124.         
  125.     return output;
  126. }
  127.  
  128.  
  129. //------------------------------------------------------------------------------------------------------
  130. // CVS_Blend2_Output    VSBlend2 (const CVS_Base_Input input)
  131. //
  132. // position tranfer
  133. // uv transfer and replication on 2 channels (UV correction is applied)
  134. //------------------------------------------------------------------------------------------------------
  135. CVS_Blend2_Output    VSBlend2 (const CVS_Base_Input input)
  136. {
  137.     CVS_Blend2_Output output;
  138.     
  139.     // output position into world+view+projection space
  140.     output.Position = input.Position;
  141.         
  142.     // Diffuse Uv output
  143.     float2 vCorrectedUV = input.DiffuseUv + (0.5f/TextureWidth, 0.5f/TextureHeight);
  144.     output.DiffuseUv1        = vCorrectedUV;
  145.     output.DiffuseUv2        = vCorrectedUV;    
  146.     
  147.     return output;
  148. }
  149.  
  150.  
  151. //------------------------------------------------------------------------------------------------------
  152. // CVS_Blend3_Output    VSBlend3 (const CVS_Base_Input input)
  153. //
  154. // position tranfer
  155. // uv transfer and replication on 3 channels (UV correction is applied)
  156. //------------------------------------------------------------------------------------------------------
  157. CVS_Blend3_Output    VSBlend3 (const CVS_Base_Input input)
  158. {
  159.     CVS_Blend3_Output output;
  160.     
  161.     // output position into world+view+projection space
  162.     output.Position = input.Position;
  163.         
  164.     // Diffuse Uv output
  165.     float2 vCorrectedUV = input.DiffuseUv + (0.5f/TextureWidth, 0.5f/TextureHeight);
  166.     output.DiffuseUv1        = vCorrectedUV;
  167.     output.DiffuseUv2        = vCorrectedUV;    
  168.     output.DiffuseUv3        = vCorrectedUV;    
  169.     
  170.     return output;
  171. }
  172.  
  173.  
  174. //------------------------------------------------------------------------------------------------------
  175. // CVS_Blend4_Output    VSBlend4 (const CVS_Base_Input input)
  176. //
  177. // position tranfer
  178. // uv transfer and replication on 4 channels (UV correction is applied)
  179. //------------------------------------------------------------------------------------------------------
  180. CVS_Blend4_Output    VSBlend4 (const CVS_Base_Input input)
  181. {
  182.     CVS_Blend4_Output output;
  183.     
  184.     // output position into world+view+projection space
  185.     output.Position = input.Position;
  186.         
  187.     // Diffuse Uv output
  188.     float2 vCorrectedUV = input.DiffuseUv + (0.5f/TextureWidth, 0.5f/TextureHeight);
  189.     output.DiffuseUv1        = vCorrectedUV;
  190.     output.DiffuseUv2        = vCorrectedUV;    
  191.     output.DiffuseUv3        = vCorrectedUV;    
  192.     output.DiffuseUv4        = vCorrectedUV;    
  193.     
  194.     return output;
  195. }
  196.  
  197.  
  198. //------------------------------------------------------------------------------------------------------
  199. // CVS_Blur_Output    HorizontalBlurVS (const CVS_Base_Input input)
  200. //
  201. // horizontal 4 sample uv computation and transfer  -=0=-
  202. //------------------------------------------------------------------------------------------------------
  203. CVS_Blur_Output    HorizontalBlurVS (const CVS_Base_Input input)
  204. {
  205.     CVS_Blur_Output output;
  206.     
  207.     // output position into world+view+projection space
  208.     output.Position = input.Position;
  209.         
  210.     // Diffuse Uv output using neighbour sampling!!        
  211.     float OffsetU     = BlurStrength/TextureWidth;                                // a whole BlurStrength * width_pixel of offset
  212.     float2 DeltaUV = (0.5f/TextureWidth, 0.5f/TextureHeight);    // screen grid align (half of a pixel in both directions
  213.     
  214.     DeltaUV.x -= OffsetU;
  215.     output.DiffuseN0 = saturate(input.DiffuseUv + DeltaUV); // one pixel to the left
  216.  
  217.     DeltaUV.x -= OffsetU;
  218.     output.DiffuseN1 = saturate(input.DiffuseUv + DeltaUV); // two pixels to the left
  219.  
  220.     DeltaUV.x += 3.0f*OffsetU;
  221.     output.DiffuseN2 = saturate(input.DiffuseUv + DeltaUV); // one pixel to the right
  222.     
  223.     DeltaUV.x += OffsetU;    
  224.     output.DiffuseN3 = saturate(input.DiffuseUv + DeltaUV);    // two pixels to the right
  225.         
  226.     return output;
  227. }
  228.  
  229.  
  230. //------------------------------------------------------------------------------------------------------
  231. // CVS_Blur_Output    VerticalBlurVS (const CVS_Base_Input input)
  232. //
  233. // vertical 4 sample uv computation and transfer
  234. //------------------------------------------------------------------------------------------------------
  235. CVS_Blur_Output    VerticalBlurVS (const CVS_Base_Input input)
  236. {
  237.     CVS_Blur_Output output;
  238.     
  239.     // output position into world+view+projection space
  240.     output.Position = input.Position;
  241.         
  242.     // Diffuse Uv output using neighbour sampling!!
  243.     float OffsetV     = BlurStrength/TextureHeight;                            // a whole BlurStrength * height_pixel of offset (blur * (1.0f / TexHeight) )
  244.     float2 DeltaUV = (0.5f/TextureWidth, 0.5f/TextureHeight);    // screen grid align (half of a pixel in both directions
  245.     
  246.     DeltaUV.y -= OffsetV;
  247.     output.DiffuseN0 = saturate(input.DiffuseUv + DeltaUV); // one pixel up
  248.  
  249.     DeltaUV.y -= OffsetV;
  250.     output.DiffuseN1 = saturate(input.DiffuseUv + DeltaUV); // two pixels up
  251.  
  252.     DeltaUV.y += 3.0f*OffsetV;
  253.     output.DiffuseN2 = saturate(input.DiffuseUv + DeltaUV); // one pixel down
  254.     
  255.     DeltaUV.y += OffsetV;    
  256.     output.DiffuseN3 = saturate(input.DiffuseUv + DeltaUV);    // two pixels down
  257.         
  258.     return output;
  259. }
  260.  
  261.  
  262. //------------------------------------------------------------------------------------------------------
  263. //                                                                            TECHNIQUES DEFINITIONS
  264. //------------------------------------------------------------------------------------------------------
  265. technique    BaseRender
  266. <
  267.     int Priority = 1;
  268.     int TechniqueIndex = 0;
  269.     int DeviceType = HWSHADER_ONLY;
  270.     int LightingType = INTEGRATED_LIGHTING;
  271.     string RenderingType = "Standard";
  272. >
  273. {
  274.     pass pass1
  275.     {
  276.         Texture[0]                = <SourceTexture1>;
  277.         MinFilter[0]            = LINEAR;
  278.         MagFilter[0]            = LINEAR;
  279.         MipFilter[0]            = NONE; //no mipmaps.
  280.         AddressU[0]                = CLAMP;
  281.         AddressV[0]                = CLAMP;
  282.         AlphaBlendEnable        = false;
  283.         AlphaTestEnable            = false;
  284.         FogEnable                = false;
  285.         
  286.         CullMode            = NONE;
  287.         ZEnable                = false;
  288.         ZWriteEnable    = false;
  289.         
  290.         VertexShader = compile vs_1_1 VSBase();
  291.         
  292.         PixelShader = 
  293.         asm
  294.         {
  295.             ps_1_1    
  296.                             
  297.             tex        t0        // source texture
  298.                         
  299.             mov r0, t0    // simple output
  300.         };
  301.     }
  302. }
  303.  
  304. //------------------------------------------------------------------------------------------------------
  305. //------------------------------------------------------------------------------------------------------
  306. //------------------------------------------------------------------------------------------------------
  307. technique    Blended2Render
  308. <
  309.     int Priority = 1;
  310.     int TechniqueIndex = 1;
  311.     int DeviceType = HWSHADER_ONLY;
  312.     int LightingType = INTEGRATED_LIGHTING;
  313.     string RenderingType = "Standard";
  314. >
  315. {
  316.     pass pass1
  317.     {
  318.         Texture  [0]        = <SourceTexture1>;
  319.         MinFilter[0]        = LINEAR;
  320.         MagFilter[0]        = LINEAR;
  321.         MipFilter[0]        = POINT;
  322.         AddressU [0]        = CLAMP;
  323.     AddressV [0]        = CLAMP;
  324.               
  325.         Texture  [1]        = <SourceTexture2>;
  326.         MinFilter[1]        = LINEAR;
  327.         MagFilter[1]        = LINEAR;
  328.         MipFilter[1]        = POINT;
  329.         AddressU [1]        = CLAMP;
  330.     AddressV [1]        = CLAMP;              
  331.                  
  332.         AlphaBlendEnable    = false;
  333.         AlphaTestEnable        = false;
  334.         FogEnable            = false;        
  335.         
  336.         CullMode                = NONE;
  337.         ZEnable                    = false;
  338.         ZWriteEnable        = false;
  339.         
  340.         VertexShader = compile vs_1_1 VSBlend2();
  341.             
  342.         // c0: SourceTexture1 weight
  343.         // c1: SourceTexture2 weight
  344.         PixelShaderConstant[0] = <WeightSource1>;
  345.         PixelShaderConstant[1] = <WeightSource2>;
  346.         
  347.         PixelShader = 
  348.         asm
  349.         {
  350.             ps.1.1                                    
  351.                         
  352.             tex t0
  353.             tex t1
  354.  
  355.             mul r0, c0, t0
  356.             mad_sat r0, c1, t1, r0 // weighted additive blend.                        
  357.         };
  358.     }
  359. }
  360.  
  361. //------------------------------------------------------------------------------------------------------
  362. //------------------------------------------------------------------------------------------------------
  363. //------------------------------------------------------------------------------------------------------
  364. technique    Blended3Render
  365. <
  366.     int Priority = 1;
  367.     int TechniqueIndex = 2;
  368.     int DeviceType = HWSHADER_ONLY;
  369.     int LightingType = INTEGRATED_LIGHTING;
  370.     string RenderingType = "Standard";
  371. >
  372. {
  373.     pass pass1
  374.     {
  375.         Texture  [0]        = <SourceTexture1>;
  376.         MinFilter[0]        = LINEAR;
  377.         MagFilter[0]        = LINEAR;
  378.         MipFilter[0]        = POINT;
  379.         AddressU [0]        = CLAMP;
  380.     AddressV [0]        = CLAMP;
  381.               
  382.         Texture  [1]        = <SourceTexture2>;
  383.         MinFilter[1]        = LINEAR;
  384.         MagFilter[1]        = LINEAR;
  385.         MipFilter[1]        = POINT;
  386.         AddressU [1]        = CLAMP;
  387.     AddressV [1]        = CLAMP;   
  388.     
  389.     Texture  [2]        = <SourceTexture3>;
  390.         MinFilter[2]        = LINEAR;
  391.         MagFilter[2]        = LINEAR;
  392.         MipFilter[2]        = POINT;
  393.         AddressU [2]        = CLAMP;
  394.     AddressV [2]        = CLAMP;                   
  395.                  
  396.         AlphaBlendEnable    = false;
  397.         AlphaTestEnable        = false;
  398.         FogEnable            = false;    
  399.         
  400.         CullMode                = NONE;
  401.         ZEnable                    = false;
  402.         ZWriteEnable        = false;
  403.         
  404.         VertexShader = compile vs_1_1 VSBlend3();
  405.             
  406.         // c0: SourceTexture1 weight
  407.         // c1: SourceTexture2 weight
  408.         // c2: SourceTexture3 weight
  409.         PixelShaderConstant[0] = <WeightSource1>;
  410.         PixelShaderConstant[1] = <WeightSource2>;
  411.         PixelShaderConstant[2] = <WeightSource3>;
  412.         
  413.         PixelShader = 
  414.         asm
  415.         {
  416.             ps.1.1                                    
  417.                         
  418.             tex t0
  419.             tex t1
  420.             tex t2
  421.  
  422.             mul            r0, c0, t0
  423.             mad            r0, c1, t1, r0
  424.             mad_sat r0, c2, t2, r0 
  425.         };
  426.     }
  427. }
  428.  
  429.  
  430. //------------------------------------------------------------------------------------------------------
  431. //------------------------------------------------------------------------------------------------------
  432. //------------------------------------------------------------------------------------------------------
  433. technique    Blended4Render
  434. <
  435.     int Priority = 1;
  436.     int TechniqueIndex = 3;
  437.     int DeviceType = HWSHADER_ONLY;
  438.     int LightingType = INTEGRATED_LIGHTING;
  439.     string RenderingType = "Standard";
  440. >
  441. {
  442.     pass pass1
  443.     {
  444.         Texture  [0]        = <SourceTexture1>;
  445.         MinFilter[0]        = LINEAR;
  446.         MagFilter[0]        = LINEAR;
  447.         MipFilter[0]        = POINT;
  448.         AddressU [0]        = CLAMP;
  449.     AddressV [0]        = CLAMP;
  450.               
  451.         Texture  [1]        = <SourceTexture2>;
  452.         MinFilter[1]        = LINEAR;
  453.         MagFilter[1]        = LINEAR;
  454.         MipFilter[1]        = POINT;
  455.         AddressU [1]        = CLAMP;
  456.     AddressV [1]        = CLAMP;   
  457.     
  458.     Texture  [2]        = <SourceTexture3>;
  459.         MinFilter[2]        = LINEAR;
  460.         MagFilter[2]        = LINEAR;
  461.         MipFilter[2]        = POINT;
  462.         AddressU [2]        = CLAMP;
  463.     AddressV [2]        = CLAMP;                   
  464.     
  465.     Texture  [3]        = <SourceTexture4>;
  466.         MinFilter[3]        = LINEAR;
  467.         MagFilter[3]        = LINEAR;
  468.         MipFilter[3]        = POINT;
  469.         AddressU [3]        = CLAMP;
  470.     AddressV [3]        = CLAMP;       
  471.                  
  472.         AlphaBlendEnable    = false;
  473.         AlphaTestEnable        = false;
  474.         FogEnable            = false;    
  475.         
  476.         CullMode                = NONE;
  477.         ZEnable                    = false;
  478.         ZWriteEnable        = false;
  479.         
  480.         VertexShader = compile vs_1_1 VSBlend4();
  481.             
  482.         // c0: SourceTexture1 weight
  483.         // c1: SourceTexture2 weight
  484.         // c2: SourceTexture3 weight
  485.         // c3: SourceTexture4 weight
  486.         PixelShaderConstant[0] = <WeightSource1>;
  487.         PixelShaderConstant[1] = <WeightSource2>;
  488.         PixelShaderConstant[2] = <WeightSource3>;
  489.         PixelShaderConstant[3] = <WeightSource4>;
  490.         
  491.         PixelShader = 
  492.         asm
  493.         {
  494.             ps.1.1                                    
  495.                         
  496.             tex t0
  497.             tex t1
  498.             tex t2
  499.             tex    t3
  500.  
  501.             mul            r0, c0, t0
  502.             mad            r0, c1, t1, r0
  503.             mad            r0, c2, t2, r0
  504.             mad_sat r0, c3, t3, r0 
  505.         };
  506.     }
  507. }
  508.  
  509.  
  510. //------------------------------------------------------------------------------------------------------
  511. //------------------------------------------------------------------------------------------------------
  512. //------------------------------------------------------------------------------------------------------
  513. technique    HorizontalBlurSample4
  514. <
  515.     int Priority = 1;
  516.     int TechniqueIndex = 4;
  517.     int DeviceType = HWSHADER_ONLY;
  518.     int LightingType = INTEGRATED_LIGHTING;
  519.     string RenderingType = "Standard";
  520. >
  521. {
  522.     pass pass1
  523.     {
  524.         Texture  [0]        = <SourceTexture1>;
  525.         MinFilter[0]        = LINEAR;
  526.         MagFilter[0]        = LINEAR;
  527.         MipFilter[0]        = POINT;
  528.         AddressU [0]        = CLAMP;
  529.     AddressV [0]        = CLAMP;
  530.         
  531.     Texture  [1]        = <SourceTexture1>;
  532.         MinFilter[1]        = LINEAR;
  533.         MagFilter[1]        = LINEAR;
  534.         MipFilter[1]        = POINT;
  535.         AddressU [1]        = CLAMP;
  536.     AddressV [1]        = CLAMP;
  537.         
  538.     Texture  [2]        = <SourceTexture1>;
  539.         MinFilter[2]        = LINEAR;
  540.         MagFilter[2]        = LINEAR;
  541.         MipFilter[2]        = POINT;
  542.         AddressU [2]        = CLAMP;
  543.     AddressV [2]        = CLAMP;
  544.         
  545.     Texture  [3]        = <SourceTexture1>;
  546.         MinFilter[3]        = LINEAR;
  547.         MagFilter[3]        = LINEAR;
  548.         MipFilter[3]        = POINT;
  549.         AddressU [3]        = CLAMP;
  550.     AddressV [3]        = CLAMP;
  551.         
  552.         AlphaBlendEnable    = false;
  553.         AlphaTestEnable        = false;
  554.         FogEnable            = false;    
  555.         
  556.         CullMode                    = NONE;
  557.         ZEnable                        = false;
  558.         ZWriteEnable            = false;
  559.         
  560.         VertexShader = compile vs_1_1 HorizontalBlurVS();
  561.         
  562.         //PixelShaderConstant[1]=<BlurColor>;
  563.         
  564.         PixelShader = 
  565.         asm
  566.         {
  567.             ps.1.1
  568.  
  569.             def c0, 0.0f,0.0f,0.0f,1.0f 
  570.             def c1, 0.35f,0.35f,0.35f,0.35f //blur weights of inner samples which may be resulting in colored blur if not equals
  571.             def c2, 0.15f,0.15f,0.15f,0.15f //blur weights of outer samples
  572.  
  573.             tex t0
  574.             tex t1
  575.             tex t2
  576.             tex t3
  577.  
  578.             mul r0.rgb, t0, c1 + mov r0.a, c0.a
  579.             mad r0.rgb, t1, c2, r0
  580.             mad r0.rgb, t2, c1, r0
  581.             mad r0.rgb, t3, c2, r0                                    
  582.         };
  583.     }
  584. }
  585. //------------------------------------------------------------------------------------------------------
  586. //------------------------------------------------------------------------------------------------------
  587. //------------------------------------------------------------------------------------------------------
  588. technique    VerticalBlurSample4
  589. <
  590.     int Priority = 1;
  591.     int TechniqueIndex = 5;
  592.     int DeviceType = HWSHADER_ONLY;
  593.     int LightingType = INTEGRATED_LIGHTING;
  594.     string RenderingType = "Standard";
  595. >
  596. {
  597.     pass pass1
  598.     {
  599.         Texture  [0]        = <SourceTexture1>;
  600.         MinFilter[0]        = LINEAR;
  601.         MagFilter[0]        = LINEAR;
  602.         MipFilter[0]        = POINT;
  603.         AddressU [0]        = CLAMP;
  604.     AddressV [0]        = CLAMP;
  605.         
  606.     Texture  [1]        = <SourceTexture1>;
  607.         MinFilter[1]        = LINEAR;
  608.         MagFilter[1]        = LINEAR;
  609.         MipFilter[1]        = POINT;
  610.         AddressU [1]        = CLAMP;
  611.     AddressV [1]        = CLAMP;
  612.         
  613.         Texture  [2]        = <SourceTexture1>;
  614.         MinFilter[2]        = LINEAR;
  615.         MagFilter[2]        = LINEAR;
  616.         MipFilter[2]        = POINT;
  617.         AddressU [2]        = CLAMP;
  618.     AddressV [2]        = CLAMP;
  619.         
  620.     Texture  [3]        = <SourceTexture1>;
  621.         MinFilter[3]        = LINEAR;
  622.         MagFilter[3]        = LINEAR;
  623.         MipFilter[3]        = POINT;
  624.         AddressU [3]        = CLAMP;
  625.     AddressV [3]        = CLAMP;
  626.         
  627.         AlphaBlendEnable    = false;
  628.         AlphaTestEnable        = false;
  629.         FogEnable            = false;            
  630.         
  631.         CullMode            = NONE;
  632.         ZEnable                = false;
  633.         ZWriteEnable    = false;
  634.         
  635.         VertexShader = compile vs_1_1 VerticalBlurVS();
  636.         
  637.         PixelShader = 
  638.         asm
  639.         {
  640.             ps.1.1
  641.  
  642.             def c0, 0.0f,0.0f,0.0f,1.0f        
  643.             def c1, 0.35f,0.35f,0.35f,0.35f //blur weights of inner samples which may be resulting in colored blur if not equals
  644.             def c2, 0.15f,0.15f,0.15f,0.15f //blur weights of outer samples            
  645.  
  646.             tex t0
  647.             tex t1
  648.             tex t2
  649.             tex t3
  650.  
  651.             mul r0.rgb, t0, c1 + mov r0.a, c0.a
  652.             mad r0.rgb, t1, c2, r0
  653.             mad r0.rgb, t2, c1, r0
  654.             mad r0.rgb, t3, c2, r0                
  655.         };
  656.     }
  657. }
  658. //------------------------------------------------------------------------------------------------------
  659. //------------------------------------------------------------------------------------------------------
  660. //------------------------------------------------------------------------------------------------------
  661. technique    GlowMapBuild
  662. <
  663.     int Priority = 1;
  664.     int TechniqueIndex = 6;
  665.     int DeviceType = HWSHADER_ONLY;
  666.     int LightingType = INTEGRATED_LIGHTING;
  667.     string RenderingType = "Standard";
  668. >
  669. {
  670.     pass pass1
  671.     {
  672.         Texture  [0]        = <SourceTexture1>;
  673.         MinFilter[0]        = LINEAR;
  674.         MagFilter[0]        = LINEAR;
  675.         MipFilter[0]        = POINT;
  676.         AddressU [0]        = CLAMP;
  677.     AddressV [0]        = CLAMP;
  678.                  
  679.         AlphaBlendEnable    = false;
  680.         AlphaTestEnable        = false;
  681.         FogEnable            = false;            
  682.         
  683.         CullMode            = NONE;
  684.         ZEnable                = false;
  685.         ZWriteEnable    = false;
  686.         
  687.         VertexShader = compile vs_1_1 VSBase();
  688.         
  689.         PixelShaderConstant[0]=<GlowThreshold>;
  690.         
  691.         PixelShader = 
  692.         asm
  693.         {
  694.             ps.1.1
  695.             
  696.             def c1, 0.30f,0.59f,0.11f,0.0f    //constantes de luminance. pour conversion de la scene en Noir & Blanc
  697.             def c2, 0.0f,0.0f,0.0f,0.0f            // zero, what we take for the glowmap where it is not supposed to glow
  698.             def c3, 0.5f,0.5f,0.5f,0.5f            // to bias the cnd level
  699.                         
  700.             tex t0
  701.  
  702.             //je veux en fonction des couleurs de la texture masquer ou pas pour le glow
  703.             //allons zo!! il suffit de convertir en N&B!!!
  704.             
  705.             dp3 r0.rgba, t0, c1  //conversion en N&B, j ecris aussi et surtout dans l alpha.
  706.             
  707.             //bon on va essayer de prendre en compte le glow parametre user.
  708.             sub r0.a, r0, c0            // (rendu noir et blanc - seuil glow)
  709.             add_sat r0.a, r0, c3    //  le seuil du cnd est a 0.5 en hardware, pour couper ou on veut, on biaise notre seuil
  710.             cnd r0, r0.a, t0, c2    //  et masquage avec l alpha seuil, on construit la glow map en prenant le diffuse ou zero selon le seuil.                    
  711.         };
  712.     }
  713. }
  714. //---------------------------------------------------------------------------------
  715. //---------------------------------------------------------------------------------
  716. //---------------------------------------------------------------------------------
  717.  
  718. technique    PostProcessConvertToLuminance
  719. <
  720.     int Priority = 1;
  721.     int TechniqueIndex = 7;
  722.     int DeviceType = HWSHADER_ONLY;
  723.     int LightingType = INTEGRATED_LIGHTING;
  724.     string RenderingType = "Standard";
  725. >
  726. {
  727.     pass pass1
  728.     {
  729.         Texture[0]            = <SourceTexture1>;
  730.         MinFilter[0]        = LINEAR;
  731.         MagFilter[0]        = LINEAR;
  732.         MipFilter[0]        = POINT; //no mipmaps.
  733.         AddressU[0]            = CLAMP;
  734.     AddressV[0]            = CLAMP;
  735.         
  736.         AlphaBlendEnable    = false;
  737.         AlphaTestEnable        = false;
  738.         FogEnable            = false;            
  739.         
  740.         CullMode            = NONE;
  741.         ZEnable                = false;
  742.         ZWriteEnable    = false;
  743.         
  744.         VertexShader = compile vs_1_1 VSBase();
  745.         
  746.         PixelShader = 
  747.         asm
  748.         {
  749.             ps_1_1    
  750.                 
  751.             def c1, 0.30f,0.59f,0.11f,0.0f    //constantes de luminance.             
  752.                 
  753.             tex        t0    // source texture
  754.             
  755.             dp3_sat r0.rgb, t0, c1 + mov r0.a, t0.a            
  756.         };
  757.     }
  758. }
  759.  
  760. //------------------------------------------------------------------------------------------------------
  761. //------------------------------------------------------------------------------------------------------
  762. //------------------------------------------------------------------------------------------------------
  763.  
  764. technique    FadeToColor
  765. <
  766.     int Priority = 1;
  767.     int TechniqueIndex = 8;
  768.     int DeviceType = HWSHADER_ONLY;
  769.     int LightingType = INTEGRATED_LIGHTING;
  770.     string RenderingType = "Standard";
  771. >
  772. {
  773.     pass pass1
  774.     {
  775.         Texture  [0]        = <SourceTexture1>;
  776.         MinFilter[0]        = LINEAR;
  777.         MagFilter[0]        = LINEAR;
  778.         MipFilter[0]        = NONE;
  779.         AddressU [0]        = CLAMP;
  780.     AddressV [0]        = CLAMP;                               
  781.                  
  782.         AlphaBlendEnable    = false;
  783.         AlphaTestEnable        = false;
  784.         FogEnable            = false;
  785.         
  786.         CullMode                = NONE;
  787.         ZEnable                    = false;
  788.         ZWriteEnable        = false;
  789.         
  790.         
  791.         VertexShader = compile vs_1_1 VSBase();                    
  792.         
  793.         PixelShaderConstant[0]        = <Color>;        
  794.         PixelShaderConstant[1]        = <Time>;
  795.         
  796.         PixelShader = 
  797.         asm
  798.         {
  799.             ps.1.1                                    
  800.     
  801.             //def c1, 1.0f, 1.0f, 1.0f, 1.0f
  802.                         
  803.             tex t0            
  804.  
  805.             lrp r0, c1, c0, t0 // r0 = Time * FadeColor + (1-Time) * texture   <=  full tex when time = 0;
  806.         };
  807.     }
  808. }
  809.  
  810. //------------------------------------------------------------------------------------------------------
  811. // ...T'N'L TECHINQUES...TODO TODO TODO TODO...
  812. //------------------------------------------------------------------------------------------------------
  813.  
  814. technique    techTnL_0
  815. <
  816.     int Priority = 1;
  817.     int TechniqueIndex = 0;
  818.     int DeviceType = TNL_ONLY;
  819.     int LightingType = INTEGRATED_LIGHTING;
  820.     string RenderingType = "Standard";
  821. >
  822. {
  823.     pass pass1
  824.     {
  825.         WorldTransform[0]    = <WorldCameraProjection>;
  826.         
  827.         Texture[0]                = <SourceTexture1>;
  828.         
  829.         ColorArg1[0]            = TEXTURE;
  830.         ColorOp[0]                = SELECTARG1;
  831.         AlphaArg1[0]            = TEXTURE;
  832.         AlphaOp[0]                = SELECTARG1;
  833.         
  834.         ColorOp[1]                = DISABLE;
  835.         AlphaOp[1]                = DISABLE;
  836.         
  837.         MinFilter[0]            = LINEAR;
  838.         MagFilter[0]            = LINEAR;
  839.         MipFilter[0]            = POINT;
  840.         
  841.         AddressU[0]                = CLAMP;
  842.     AddressV[0]                = CLAMP;
  843.         
  844.         CullMode                    = CW;
  845.         ZEnable                        = true;
  846.         ZFunc                            = LESSEQUAL;
  847.         ZWriteEnable            = true;
  848.         AlphaBlendEnable    = false;
  849.         AlphaTestEnable        = true;
  850.         AlphaRef                    = 192;
  851.         AlphaFunc                    = GREATEREQUAL;
  852.         FogEnable            = false;    
  853.         
  854.         VertexShader             = NULL;        
  855.         PixelShader             = NULL;
  856.     }
  857. }
  858.  
  859. //------------------------------------------------------------------------------------------------------
  860. //------------------------------------------------------------------------------------------------------
  861. //------------------------------------------------------------------------------------------------------
  862.  
  863.  
  864. //------------------------------------------------------------------------------------------------------
  865. //------------------------------------------------------------------------------------------------------
  866. //------------------------------------------------------------------------------------------------------
  867.